import { AppTokenObj } from "../dao/AppToken"
import { AddCollectParam, CollectParma, CollectRepository } from "../repo/CollectRepository"

export class CollectCtx {
  private static inst: CollectCtx
  private collectRepo: CollectRepository = CollectRepository.getInstance()

  // 单例
  public static getInstance() {
    if (!CollectCtx.inst) {
      CollectCtx.inst = new CollectCtx()
    }

    return CollectCtx.inst
  }

  async collect(params: CollectParma, customer: number) {
    return (await this.collectRepo.collect(params, customer))[0]
  }

  addCollect(params: AddCollectParam, customer: AppTokenObj["userId"]) { 
    return this.collectRepo.addCollect(params, customer)
  }

  delCollect(collectId: number, customer: AppTokenObj["userId"]) { 
    return this.collectRepo.delCollect(collectId, customer)
  }
}